<%@ include file="/WEB-INF/controllers/configuration/includes.jsp"%>
<script type="text/javascript">
var h = 0;
$(document).ready(function() {
	h = $('#lvl1menu  .nav-element').size();
	h = h  * 44;	
});
$('#nav-button').live('click',function () {
	var height = $(".nav-collapse").css('height'); 
	if(height == '0px'){
		$(".nav-collapse").animate({
			height: h+"px"}, 400,'easeInOutExpo' );
	}else{
		$(".nav-collapse").animate({
			height: "0"}, 400 , 'easeInOutExpo' );
	}
});

$('#nav-logout').live('click',function () {
	document.location.href='<c:url value='/logout'/>'; 
});
$('.nav-element').live('mousedown',function(e) {
	var link = $(this).find('a').attr('contextMenu');
// 	alert(link);
	 if(e.which == 2 ){
//  		 && $(e.target).get(0).tagName != 'A'){

		 window.open(link,"_blank");
	 }else if(e.which == 1){		
		document.location.href=link;
	 }
});
</script>
<div id="lvl1menu">
	<div id="nav-buttons-container">
		<span id="nav-button" class="clickeable transition"></span>
		<span id="nav-logout" class="clickeable transition"></span>
	</div>
	<div class="nav-collapse collapsed">
		<ul>		
			<c:if test="${sessionScope.SPRING_SECURITY_CONTEXT.authentication!=null}">
				<c:set var="infoGroup" value="${fn:replace(sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.groups, '[', '')}"/>
				<c:set var="infoGroup" value="${fn:replace(infoGroup, ']', '')}"/>
				<c:set var="infoUser" value="${sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.name} ${sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.surname} (${infoGroup})"/>
				<li>
					<a href="<c:url value="/privado/userConfiguration.do"/>">
						<span id="menuUserConfiguration" class="clickeable" title="${infoUser}"></span>
					</a>
				</li>
 				<li id="menuGestionPerfiles" class="">
 					
						<span class="negrita">
<%-- 							${sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.groups} --%>
						</span>
<%-- 							${sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.name} --%>
<%-- 							${sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.surname} --%>
							
				</li> 
				<sec:authorize ifAnyGranted="ROLE_ADMINISTRATOR">
					<li class="nav-element clickeable">
						<a id="menuGestionUsuarios" contextMenu="<c:url value="/privado/listUser.do"/>" href="<c:url value="/privado/listUser.do"/>">Usuarios</a>
					</li>
				</sec:authorize>
				<sec:authorize ifAnyGranted="ROLE_ADVANCED_MANAGER"> 
					<li class="nav-element clickeable">
						<a id="menuPortada"
                                       contextmenu="<c:url value="/privado/inicio.do"/>" onclick="cleanAllSessionForms('<c:url value="/privado/inicio.do"/>');"><spring:message code="label.title.menu.portada"/></a>
					</li>
					<li class="nav-element clickeable">
						<a id="menuGraficaTweets"
                                       contextmenu="<c:url value="/privado/graficaTweets.do"/>" onclick="cleanAllSessionForms('<c:url value="/privado/graficaTweets.do"/>');"><spring:message code="label.title.graficatweets"/></a>
					</li>
					<li class="nav-element clickeable">
						<a id="menuTimeline"
                                       contextmenu="<c:url value="/privado/timeline.do"/>" onclick="cleanAllSessionForms('<c:url value="/privado/timeline.do"/>');"><spring:message code="label.title.timeline"/></a>
					</li>
				</sec:authorize>
					<li id="disconectLinkContainer">
						<a href="<c:url value='/logout'/>" id="disconectLink" class="clickeable"></a>				
					</li>
			</c:if>
		</ul>
	</div>
</div>